<?php

namespace app\index\controller\location;

use app\index\model\UM as UM;
use app\index\service\AreaService;
use ShidianUtil\Thinkphp\Response\ApiResponse;
use think\APP;
use think\Request as Request;

/**
 * Area 控制器
 * Class Area
 * @package app\location\controller
 * @link https://www.kancloud.cn/manual/thinkphp6_0/1037509
 */
class Area
{
    // 请求参数
    private Request $request;

    // service
    private AreaService $service;

    public function __construct(Request $request, AreaService $areaService)
    {
        $this->request = $request;
        $this->service = $areaService;
    }


    /**
     * 使用经纬度查询城市
     * @param \app\index\model\UM|null $user
     * @return ApiResponse
     * @url /location/area/read
     */
    public function read(?UM $user): ApiResponse
    {
        $request = $this->request;

        return ApiResponse::success($this->service->read($user, $request->param()));
    }
}
